\doxysection{C\+:/\+Users/\+ASUS/\+Desktop/dm-\/ctrl\+H7-\/balance-\/9025test/\+Tasks/remote\+Task.c File Reference}
\hypertarget{remote_task_8c}{}\label{remote_task_8c}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/Tasks/remoteTask.c@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/Tasks/remoteTask.c}}


遥控器接受与发送的任务（没有写在\+DMA）  


{\ttfamily \#include "{}cmsis\+\_\+os.\+h"{}}\newline
{\ttfamily \#include "{}tim.\+h"{}}\newline
{\ttfamily \#include "{}delayticks.\+h"{}}\newline
{\ttfamily \#include "{}remote\+Task.\+h"{}}\newline
{\ttfamily \#include "{}string.\+h"{}}\newline
{\ttfamily \#include "{}usart.\+h"{}}\newline
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{remote_task_8c_a8787210b33220cae4837fbbfac16e494}\label{remote_task_8c_a8787210b33220cae4837fbbfac16e494} 
\#define {\bfseries SBUS\+\_\+\+HEAD}~0\+X0F
\item 
\Hypertarget{remote_task_8c_aff883458bb781ec304e987febccb2387}\label{remote_task_8c_aff883458bb781ec304e987febccb2387} 
\#define {\bfseries SBUS\+\_\+\+END}~0\+X00
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{remote_task_8c_a3b6ae96f6a43397f92b8d7a6a0583d8d}{sbus\+\_\+frame\+\_\+parse}} (\mbox{\hyperlink{structremoter__t}{remoter\+\_\+t}} \texorpdfstring{$\ast$}{*}remoter, \mbox{\hyperlink{structrc__ctrl__t}{rc\+\_\+ctrl\+\_\+t}} \texorpdfstring{$\ast$}{*}rc\+\_\+ctrl, uint8\+\_\+t \texorpdfstring{$\ast$}{*}buf)
\begin{DoxyCompactList}\small\item\em 解析\+SBUS帧数据 \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group___u_a_r_t___exported___functions___group2_ga925534fb8bf7ca464fd05c982fe4bfa0}{HAL\+\_\+\+UARTEx\+\_\+\+Rx\+Event\+Callback}} (\mbox{\hyperlink{group___u_a_r_t___exported___types_ga5de4a49eb132735325e706f406c69d6e}{UART\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}huart, uint16\+\_\+t Size)
\begin{DoxyCompactList}\small\item\em 每次dma/idle中断发生时，都会调用此函数.对于每个uart实例会调用对应的回调进行进一步的处理 例如\+:视觉协议解析/遥控器解析/裁判系统解析 \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group___u_a_r_t___exported___functions___group2_ga0e0456ea96d55db31de947fb3e954f18}{HAL\+\_\+\+UART\+\_\+\+Error\+Callback}} (\mbox{\hyperlink{group___u_a_r_t___exported___types_ga5de4a49eb132735325e706f406c69d6e}{UART\+\_\+\+Handle\+Type\+Def}} \texorpdfstring{$\ast$}{*}huart)
\begin{DoxyCompactList}\small\item\em 当串口发送/接收出现错误时,会调用此函数,此时这个函数要做的就是重新启动接收 \end{DoxyCompactList}\item 
\Hypertarget{remote_task_8c_af4e22bdbbf832ceb562aabf52d5ecc0a}\label{remote_task_8c_af4e22bdbbf832ceb562aabf52d5ecc0a} 
void {\bfseries remote\+Task} (void const \texorpdfstring{$\ast$}{*}argument)
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{remote_task_8c_a1f52c18f819974b09c836f5294f9dfa2}\label{remote_task_8c_a1f52c18f819974b09c836f5294f9dfa2} 
uint8\+\_\+t {\bfseries rx\+\_\+buff} \mbox{[}BUFF\+\_\+\+SIZE\mbox{]}
\item 
\Hypertarget{remote_task_8c_a59f51723db757c35aaf2f95a257fd745}\label{remote_task_8c_a59f51723db757c35aaf2f95a257fd745} 
\mbox{\hyperlink{structremoter__t}{remoter\+\_\+t}} {\bfseries remoter}
\item 
\Hypertarget{remote_task_8c_a975f19a73d3b260edb6c41baec33a3ab}\label{remote_task_8c_a975f19a73d3b260edb6c41baec33a3ab} 
\mbox{\hyperlink{structrc__ctrl__t}{rc\+\_\+ctrl\+\_\+t}} {\bfseries rc\+\_\+ctrl}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
遥控器接受与发送的任务（没有写在\+DMA） 

\begin{DoxyAuthor}{Author}
Tux\+Monkey (\href{mailto:nqx2004@gmail.com}{\texttt{nqx2004@gmail.\+com}}) 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
1.\+0 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2024-\/09-\/21
\end{DoxyDate}
\begin{DoxyCopyright}{Copyright}
Copyright (c) 2024 DLMU-\/\+C.\+ONE
\end{DoxyCopyright}
\begin{DoxyParagraph}{修改日志\+:}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{4}{|X[-1]}|}
\hline
\cellcolor{\tableheadbgcolor}\textbf{ Date }&\cellcolor{\tableheadbgcolor}\textbf{ Version }&\cellcolor{\tableheadbgcolor}\textbf{ Author }&\cellcolor{\tableheadbgcolor}\textbf{ Description }\\\cline{1-4}
\endfirsthead
\hline
\endfoot
\hline
\cellcolor{\tableheadbgcolor}\textbf{ Date }&\cellcolor{\tableheadbgcolor}\textbf{ Version }&\cellcolor{\tableheadbgcolor}\textbf{ Author }&\cellcolor{\tableheadbgcolor}\textbf{ Description }\\\cline{1-4}
\endhead
2024-\/09-\/21 &1.\+0 &Tux\+Monkey &内容 \\\cline{1-4}
\end{longtabu}

\end{DoxyParagraph}


\label{doc-func-members}
\Hypertarget{remote_task_8c_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{remote_task_8c_a3b6ae96f6a43397f92b8d7a6a0583d8d}\index{remoteTask.c@{remoteTask.c}!sbus\_frame\_parse@{sbus\_frame\_parse}}
\index{sbus\_frame\_parse@{sbus\_frame\_parse}!remoteTask.c@{remoteTask.c}}
\doxysubsubsection{\texorpdfstring{sbus\_frame\_parse()}{sbus\_frame\_parse()}}
{\footnotesize\ttfamily \label{remote_task_8c_a3b6ae96f6a43397f92b8d7a6a0583d8d} 
void sbus\+\_\+frame\+\_\+parse (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structremoter__t}{remoter\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{remoter}{, }\item[{\mbox{\hyperlink{structrc__ctrl__t}{rc\+\_\+ctrl\+\_\+t}} \texorpdfstring{$\ast$}{*}}]{rc\+\_\+ctrl}{, }\item[{uint8\+\_\+t \texorpdfstring{$\ast$}{*}}]{buf}{}\end{DoxyParamCaption})}



解析\+SBUS帧数据 

本函数用于解析来自\+SBUS遥控器的帧数据。\+SBUS是一种用于遥控模型的通信协议。 函数首先检查数据包是否以\+SBUS头部和尾部特定的字节开始和结束，以确保数据包的完整性。 如果数据包不符合预期的格式，函数将立即返回，不进行进一步处理。

对于特定的控制信号，比如当接收到0x0\+C时，标记遥控器为离线状态，其他情况下则为在线状态。 随后，函数解析数据包中的通道信号。\+SBUS协议支持多个通道，每个通道对应遥控器的一个控制输入。 这些通道的数值被解码并存储在remoter结构体的rc.\+ch数组中，供后续使用。

最后，函数维护四个静态变量来记录开关位置的最后状态，这在调试过程中用于跟踪用户输入的变化。


\begin{DoxyParams}{Parameters}
{\em remoter} & 指向remoter\+\_\+t结构体的指针，用于存储解析后的遥控器数据 \\
\hline
{\em rc\+\_\+ctrl} & 指向rc\+\_\+ctrl\+\_\+t结构体的指针，用于存储解析后的遥控器数据 \\
\hline
{\em buf} & 指向接收到的数据包的指针 \\
\hline
\end{DoxyParams}
!!调试时选择remoter放在\+Watch窗口进行调试!!!